48 research outputs found
Recursive Session Types Revisited
Session types model structured communication-based programming. In
particular, binary session types for the pi-calculus describe communication
between exactly two participants in a distributed scenario. Adding sessions to
the pi-calculus means augmenting it with type and term constructs. In a
previous paper, we tried to understand to which extent the session constructs
are more complex and expressive than the standard pi-calculus constructs. Thus,
we presented an encoding of binary session pi-calculus to the standard typed
pi-calculus by adopting linear and variant types and the continuation-passing
principle. In the present paper, we focus on recursive session types and we
present an encoding into recursive linear pi-calculus. This encoding is a
conservative extension of the former in that it preserves the results therein
obtained. Most importantly, it adopts a new treatment of the duality relation,
which in the presence of recursive types has been proven to be quite
challenging.Comment: In Proceedings BEAT 2014, arXiv:1408.556
Type systems for distributed programs: session communication
Distributed systems are everywhere around us and guaranteeing their correctness is of paramount importance. It is natural to expect that these systems interact and communicate among them to achieve a common task.
In this work, we develop techniques based on types and type systems for the verification of correctness, consistency and safety properties related to communication in complex distributed systems. We study advanced safety properties related to communication, like deadlock or lock freedom and progress. We study session types in the pi-calculus describing distributed systems and communication-centric computation. Most importantly, we de- fine an encoding of the session pi-calculus into the standard typed pi-calculus in order to understand the expressive power of these concurrent calculi. We show how to derive in the session pi-calculus basic properties, like type safety or complex ones, like progress, by exploiting this encoding
Session types revisited
Session types are a formalism used to model structured communication-based programming. A binary session type describes communication by specifying the type and direction of data exchanged between two parties. When session types and session processes are added to the syntax of standard π-calculus they give rise to additional separate syntactic categories. As a consequence, when new type features are added, there is duplication of effort in the theory: the proofs of properties must be checked both on standard types and on session types. We show that session types are encodable into standard π- types, relying on linear and variant types. Besides being an expressivity result, the encoding (i) removes the above redundancies in the syntax, and (ii) the properties of session types are derived as straightforward corollaries, exploiting the corresponding properties of standard π-types. The robustness of the encoding is tested on a few extensions of session types, including subtyping, polymorphism and higher-order communications
Semantic subtyping for objects and classes
In this paper we propose an integration of structural subtyping with boolean
connectives and semantic subtyping to define a Java-like programming language
that exploits the benefits of both techniques. Semantic subtyping is an approach
for defining subtyping relation based on set-theoretic models, rather than syntactic
rules. On the one hand, this approach involves some non trivial mathematical
machinery in the background. On the other hand, final users of the language need
not know this machinery and the resulting subtyping relation is very powerful and
intuitive. While semantic subtyping is naturally linked to the structural one, we
show how our framework can also accommodate the nominal subtyping. Several
examples show the expressivity and the practical advantages of our proposal
Typechecking protocols with Mungo and StMungo: a session type toolchain for Java
Static typechecking is an important feature of many standard programming languages. However, static typing focuses on data rather than communication, and therefore does not help programmers correctly implement communication protocols in distributed systems. The theory of session types provides a basis for tackling this problem; we use it to develop two tools that support static typechecking of communication protocols in Java. The first tool, Mungo, extends Java with typestate definitions, which allow classes to be associated with state machines defining permitted sequences of method calls: for example, communication methods. The second tool, StMungo, takes a session type describing a communication protocol, and generates a typestate specification of the permitted sequences of messages in the protocol. Protocol implementations can be validated by Mungo against their typestate definitions and then compiled with a standard Java compiler. The result is a toolchain for static typechecking of communication protocols in Java. We formalise and prove soundness of the typestate inference system used by Mungo, and show that our toolchain can be used to typecheck a client for the standard Simple Mail Transfer Protocol (SMTP)
SFJ: an Implementation of Semantic Featherweight Java
There are two approaches to defining subtyping relations: the syntactic and the semantic approach. In semantic subtyping, one defines a model of the language and an interpretation of types as subsets of this model. Subtyping is defined as inclusion of subsets denoting types.
An orthogonal subtyping question, typical of object-oriented languages, is the nominal versus the structural subtyping. Dardha et al. [11, 12] defined boolean types and semantic subtyping for Featherweight Java (FJ) and integrated both nominal and structural subtyping, thus exploiting the benefits of both approaches. However, these benefits were illustrated only at a theoretical level, but not exploited practically.
We present SFJ—Semantic Featherweight Java, an implementation of FJ which features boolean types, semantic subtyping and integrates nominal as well as structural subtyping. The benefits of SFJ, illustrated in the paper and the accompanying video (with audio/subtitles) [27], show how static type-checking of boolean types and semantic subtyping gives higher guarantees of program correctness, more flexibility and compactness of program writing
Deadlock-Free Session Types in Linear Haskell
Priority Sesh is a library for session-typed communication in Linear Haskell which offers strong compile-time correctness guarantees. Priority Sesh offers two deadlock-free APIs for session-typed communication. The first guarantees deadlock freedom by restricting the process structure to trees and forests. It is simple and composeable, but rules out cyclic structures. The second guarantees deadlock freedom via priorities, which allows the programmer to safely use cyclic structures as well. Our library relies on Linear Haskell to guarantee linearity, which leads to easy-to-write session types and more idiomatic code, and lets us avoid the complex encodings of linearity in the Haskell type system that made previous libraries difficult to use
Prioritise the Best Variation
Binary session types guarantee communication safety and session fidelity, but
alone they cannot rule out deadlocks arising from the interleaving of different
sessions. In Classical Processes (CP)a process calculus based on classical
linear logicdeadlock freedom is guaranteed by combining channel creation and
parallel composition under the same logical cut rule. Similarly, in Good
Variation (GV)a linear concurrent -calculusdeadlock freedom is
guaranteed by combining channel creation and thread spawning under the same
operation, called fork.
In both CP and GV, deadlock freedom is achieved at the expense of
expressivity, as the only processes allowed are tree-structured. Dardha and Gay
define Priority CP (PCP), which allows cyclic-structured processes and restores
deadlock freedom by using priorities, in line with Kobayashi and Padovani.
Following PCP, we present Priority GV (PGV), a variant of GV which decouples
channel creation from thread spawning. Consequently, we type cyclic-structured
processes and restore deadlock freedom by using priorities. We show that our
type system is sound by proving subject reduction and progress. We define an
encoding from PCP to PGV and prove that the encoding preserves typing and is
sound and complete with respect to the operational semantics
Prioritise the Best Variation
Binary session types guarantee communication safety and session fidelity, but alone they cannot rule out deadlocks arising from the interleaving of different sessions. In Classical Processes (CP) [53]—a process calculus based on classical linear logic—deadlock freedom is guaranteed by combining channel creation and parallel composition under the same logical cut rule. Similarly, in Good Variation (GV) [39, 54]—a linear concurrent λ-calculus—deadlock freedom is guaranteed by combining channel creation and thread spawning under the same operation, called fork. In both CP and GV, deadlock freedom is achieved at the expense of expressivity, as the only processes allowed are tree-structured. Dardha and Gay [19] define Priority CP (PCP), which allows cyclic-structured processes and restores deadlock freedom by using priorities, in line with Kobayashi and Padovani [34, 44]. Following PCP, we present Priority GV (PGV), a variant of GV which decouples channel creation from thread spawning. Consequently, we type cyclic-structured processes and restore deadlock freedom by using priorities. We show that our type system is sound by proving subject reduction and progress. We define an encoding from PCP to PGV and prove that the encoding preserves typing and is sound and complete with respect to the operational semantics
Ï€ with Leftovers: a Mechanisation in Agda
Linear type systems need to keep track of how programs use their resources. The standard approach is to use context splits specifying how resources are (disjointly) split across subterms. In this approach, context splits redundantly echo information which is already present within subterms. An alternative approach is to use leftover typing [2, 23], where in addition to the usual (input) usage context, typing judgments have also an output usage context: the leftovers. In this approach, the leftovers of one typing derivation are fed as input to the next, threading through linear resources while avoiding context splits. We use leftover typing to define a type system for a resource-aware π -calculus [26, 27], a process algebra used to model concurrent systems. Our type system is parametrised over a set of usage algebras [20, 34] that are general enough to encompass shared types (free to reuse and discard), graded types (use exactly n number of times) and linear types (use exactly once). Linear types are important in the π -calculus: they ensure privacy and safety of communication and avoid race conditions, while graded and shared types allow for more flexible programming. We provide a framing theorem for our type system, generalise the weakening and strengthening theorems to include linear types, and prove subject reduction. Our formalisation is fully mechanised in about 1850 lines of Agda [37]